package io.renren.modules.backstage.controller;



import io.renren.common.exception.Result;
import io.renren.modules.backstage.entity.BorrowerEntity;
import io.renren.modules.backstage.entity.InformationEntity;
import io.renren.common.exception.StatusCode;
import io.renren.modules.backstage.service.InformationService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;


/**
 * 信息表
 *
 * @author syh
 * @email sunlightcs@gmail.com
 * @date 2022-05-18 10:38:06
 */
@RestController
@RequestMapping("/information")
@CrossOrigin
public class InformationController {
    @Autowired
    private InformationService informationService;

    @PostMapping("/list")
    public Result getInformation(@RequestBody InformationEntity informationEntity){
        Result result= informationService.getAll(informationEntity);
        return result;
    }


    @PostMapping("/save")
    public Result save(@RequestBody InformationEntity informationEntity){
        informationService.save(informationEntity);
        return  new Result(StatusCode.OK,"添加数据成功",true);
    }

    @GetMapping("/getByProId")
    public Result getByProId(@RequestParam("productId") Integer productId){
        InformationEntity informationEntity=informationService.getByProId(productId);
        return new Result(StatusCode.OK,"添加数据成功",true,informationEntity);
    }


    @GetMapping("/getById")
    public Result getById(@RequestParam("infoId") int infoId){
       InformationEntity informationEntity= informationService.getByInFoId(infoId);
        return new Result(StatusCode.OK,"查询数据成功",true,informationEntity);
    }
}
